package com.tianhui.consignortwofei.mvp.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.mvp.model.enty.SalesManInfo;

import org.yczbj.ycrefreshviewlib.adapter.RecyclerArrayAdapter;
import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

/**
 * @author fgs
 * @date 2019/8/5
 **/
public class SalesManListAdapter extends RecyclerArrayAdapter<SalesManInfo> {
    private int selectPosition = -1;

    public SalesManListAdapter(Context context) {
        super(context);
    }

    public void setSelectPosition(int selectPosition) {
        this.selectPosition = selectPosition;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new SalesManListViewHolder(parent, R.layout.item_sales_man_list);
    }

    private class SalesManListViewHolder extends BaseViewHolder<SalesManInfo> {
        private ImageView imageView;
        private TextView nameTextView;
        private TextView phoneTextView;

        public SalesManListViewHolder(ViewGroup parent, int res) {
            super(parent, res);
            imageView = getView(R.id.item_select_dialog_imageView);
            nameTextView = getView(R.id.item_sales_man_list_nameTextView);
            phoneTextView = getView(R.id.item_sales_man_list_phoneTextView);
        }

        @Override
        public void setData(SalesManInfo data) {
            super.setData(data);
            nameTextView.setText(data.name);
            phoneTextView.setText(data.account);
//            if (selectPosition == getDataPosition()) {
//                imageView.setVisibility(View.VISIBLE);
//            } else {
//                imageView.setVisibility(View.INVISIBLE);
//            }
        }

    }

}
